import request from "@/utils/request"

//定义公共的API
const BASE_URL = "/system/itrUser";

export default {
    //用户分页查询
    getUserPageInfo(page, limit, searchObj) {
        return request({
            url: `${BASE_URL}/${page}/${limit}`,
            method: 'get',
            params: searchObj
        })
    },

    // 添加或者修改
    saveOrUpdate() {
        if (this.itripUser.id != null) {
            this.updateUser();
        } else {
            this.addUser();
        }
    },

    // 添加用户
    saveUser(user) {
        return request({
            url: `${BASE_URL}/saveOrUpdate`,
            method: 'post',
            data: user
        })
    },

    // 根据id去得到一个用户 
    getUserById(id) {
        return request({
            url: `${BASE_URL}/findUserById/${id}`,
            method: 'get'
        })
    },

    // 修改
    updateUser(user) {
        return request({
            url: `${BASE_URL}/saveOrUpdate`,
            method: 'post',
            data: user
        })
    },
    //删除
    // 根据id去删除一个用户
    removeId(id) {
        return request({
            url: `${BASE_URL}/remove/${id}`,
            method: 'delete'
        })
    },

    //批量 删除
    bactchremoveId(ids) {
        return request({
            url: `${BASE_URL}/removeBatchUserByIds`,
            method: 'delete', // 提交方式
            data: ids
        })
    },

    //状态修改
    updateStatus(id,activated){
        return request({
            url:`${BASE_URL}/updateStatus/${id}/${activated}`,
            method: 'get'
          }) 
     },
}